
<div>
  <div class="pull-right">
    <%= link_to "新建商品活动", new_admin_promotion_path, class: "btn btn-primary" %>
  </div>

  <h1>
    商品活动(<%= @promotions.total_entries %>)
  </h1>
</div>

<div>
  <table class="table table-striped">
    <tr>
      <th>标题</th>
      <th>状态</th>
      <th>开始时间</th>
      <th>结束时间</th>
      <th>描述</th>
      <th>操作</th>
    </tr>

    <% @promotions.each do |promotion| %>
      <tr>
        <td><%= promotion.title %></td>
        <td><span class="btn <%= promotion.actived ? "btn-success" : 'btn-danger' %>"><%= promotion.actived ? "有效" : "无效" %></span></td>
        <td><%= promotion.started_at.to_s %></td>
        <td><%= promotion.ended_at.to_s %></td>
        <td><%= promotion.desc %></td>
        <td>
          <%= link_to "编辑", edit_admin_promotion_path(promotion) %>
          &nbsp;&nbsp;
          |
          &nbsp;&nbsp;
          <%= link_to promotion.actived ? "暂停" : "激活", enable_or_disable_admin_promotion_path(promotion), method: "put", confirm: "确认？" %>
        </td>
      </tr>
    <% end -%>
  </table>

  <%= will_paginate @promotions %>
</div>


